#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <time.h>

#if 0
	struct timespec{  
		time_t tv_sec;		// 秒s
		long tv_nsec;		// 纳秒ns
	};  
#endif

/**
 * get_system_time_microsecond - 纳秒
 */
void get_ns()
{
	struct timespec time_start, time_end;

	clock_gettime(CLOCK_REALTIME, &time_start);
	printf("start time %llu s, %llu ns\n", (long long unsigned)time_start.tv_sec, 
                                            (long long unsigned)time_start.tv_nsec);

	clock_gettime(CLOCK_REALTIME, &time_end);
	printf("end   time %llu s, %llu ns\n", (long long unsigned)time_end.tv_sec, 
                                            (long long unsigned)time_end.tv_nsec);

	printf("duration : %llu s %llu ns\n", (long long unsigned)time_end.tv_sec - time_start.tv_sec, 
                                            (long long unsigned)time_end.tv_nsec - time_start.tv_nsec);
}

/**
 * get_system_time_microsecond - 微秒
 */
int get_system_time_microsecond(void)
{
	unsigned long long  pts_temp;
	struct timespec tp;

	clock_gettime(CLOCK_REALTIME,&tp);

	pts_temp = tp.tv_sec;
	pts_temp = pts_temp * 1000000 + tp.tv_nsec / 1000;
	printf("sys time : %lld\n", pts_temp);
	fflush(stdout);

	return 0;
}

/**
 * GetSystemTimeMs - 毫秒
 */
int64_t GetSystemTimeMs(void) {
    struct timeval cur_t;
    int64_t timeMs = 0;

    gettimeofday(&cur_t, NULL);
    timeMs = cur_t.tv_sec * 1000 + cur_t.tv_usec / 1000;

    return timeMs;
}

void main()
{
	get_system_time_microsecond();
	printf("%d\n",sizeof(unsigned long long)); 
}

